import { defineStore } from "pinia";

export const useMenuStore = defineStore("menu", {
  state: () => {
    return {
      searchContent: '',
      searchPlaceholder: '熊猫起始页',
      searchEngines: [
        {
          id: 1,
          engineName: "百度",
          url: "https://www.baidu.com/s?word=",
          icon: "icon-baidu",
        },
        {
          id: 2,
          engineName: "必应",
          url: "https://cn.bing.com/search?q=",
          icon: "icon-bing",
        },

        {
          id: 3,
          engineName: "谷歌",
          url: "https://www.google.com/search?q=",
          icon: "icon-guge",
        },
        {
          id: 4,
          engineName: "搜狗",
          url: "https://www.sogou.com/web?query=",
          icon: "icon-sogou",
        },
      ],
      searchIndex: 0,
      target_blank: true
    };
  },
  getters: {
    activatedEngine(state) {
      return state.searchEngines[state.searchIndex]
    }
  },
  actions: {
    updateSearchIndex(index) {
      this.searchIndex = index;
    }
  }
});
